@extends('Home/Layout/base')

@section('title', '欢迎光临鞋城')

@section('nav')
    @include('Home/Layout/index_nav')

@endsection


@section('main')
    <div class="sg-main wrapper">
        
        <!-- 商品列表区域 -->
        <div class="sg-content">
            <!-- 条件筛选区域 -->
            <div class="rank-menu">
                <div class="rank">

                    <div class="r-item">
                        <a class="ajax price" tag='desc' href="{{asset('goodslist?sortid=' .$sortid. '&sort=price-desc'.'&from='.$from.'&to='.$to)}}" title="价格从高到低排序">
                            价格 <span class="sort-arrow desc"></span>
                        </a>
                    </div>

                    <div class="r-item">
                        <a class="ajax price" tag='desc' href="{{asset('goodslist?sortid=' .$sortid. '&sort=price-asc'.'&from='.$from.'&to='.$to)}}"  title="价格从低到高排序">
                            价格 <span class="sort-arrow"></span>
                        </a>
                    </div>

                    <div class="r-item">
                        <a class="ajax sales" tag='desc' href="{{asset('goodslist?sortid=' .$sortid. '&sort=sales-desc'.'&from='.$from.'&to='.$to)}}" title="销量从高到低排序">
                            销量<span class="sort-arrow desc">
                        </a>
                    </div>

                    <div class="r-item">
                        <a class="ajax hot" tag='desc' href="{{asset('goodslist?sortid=' .$sortid. '&sort=hot-desc'.'&from='.$from.'&to='.$to)}}"  title="人气从高到低排序">
                            人气 <span class="sort-arrow desc">
                        </a>
                    </div>

                    <div class="r-item">
                        <!-- <a class="ajax" href="">
                            上架时间<span class="sort-arrow desc"></span>
                        </a> -->
                        <div class="sch">
                            <form action="{{asset('goodslist?sortid=' .$sortid. '&sort='.$sort. '&hehe=haha')}}" method="get">
                                {{ csrf_field() }}
                                <input type="hidden" name="sortid" value="{{$sortid}}">
                                <input type="hidden" name="sort" value="{{$sort}}">
                                价格：
                                <input name='from' type="text" class="txtin" />
                                <span class="divider">-</span>
                                <input name='to' type="text" class="txtin" />
                                <button type='submit' class="tj ui-btn-theme">确定</button>
                            </form>
                        </div>
                    </div>
                </div>

                <div class="help">
                    <!-- <label class="check"><input type="checkbox" name="" id="" />仅显示有货商品</label> -->
                    <span class="info">共<span>{{$count}}个</span>商品</span>
                    <!-- <div class="r-page">
                        <a class="prev" href="">上一页</a><a class="next" href="">下一页</a>
                    </div> -->
                </div>
            </div>
        
            <!-- 商品展示区域 -->
            <div class="sg-list clearfix">
                <!-- 当返回码为200时,遍历商品, 为404时,显示'没有找到商品'的提示 -->
                @if($msg['code'] ==  200)
                    @foreach($goods as $v)
                        @if ($v['state'] == 1 || $v['state'] == 4)      {{--只有状态为上架或促销才能遍历出来--}}
                        <div class="col col-3">
                            <div class="item">
                                <div class="inner">
                                    <a href="{{asset('goods-detail/'.$v['id'])}}"><img class="figure" src='{{asset($v["pic"])}}' alt="" /></a>
                                    <a href="{{asset('goods-detail/'.$v['id'])}}"><div class="name">{{$v['gname']}}</div><div class="price">{{$v['price']}}元</div></a>
                                    <!-- <a class="act" href=""><i class="iconfont icon-cart"></i>加入购物车</a> -->
                                </div>
                            </div>
                        </div>
                        @endif
                    @endforeach
                @elseif($msg['code'] == 404)
                    <div class="container">{{$msg['msg']}}</div>
                @endif
            </div>
            
            <!-- 分页 -->
            <br>
            <br>
            <div class="container">
                @if($msg['code'] ==  200)
                    {{
                    $goods->appends([

                        'sortid' => $sortid,
                        'sort' => $sort,
                        'from' => $from,
                        'to' => $to,

                    ])->links()
                    }}
                @endif
            </div>

        </div>

        <!-- 热销单品 -->
        <!-- 店铺热销 -->
        <div class="sg-aside">
            <div class="sg-aside-tit">
                <!-- 店铺热销 -->
                <span>店铺热销</span>
            </div>
            <div class="shop-hot">
                <!-- $hotSale是通过视图composer   ViewComposers/IndexComposer拿到的 -->
                @foreach($hotSale as $v)
                <div class="item" style="border:1px solid #cccccc; text-align: center; box-shadow:0px 1px 1px 0px;">
                    <a href=""><img class="figure" src="{{asset($v['path'])}}" alt="" /></a>
                    <div class="p-name"><a href="">{{$v['gname']}}</a></div>
                    <div class="price">¥{{$v['sale_price']}}</div>
                </div>
                @endforeach
                
            </div>
        </div>
        
    </div>
@endsection

@section('footer-js')

    @if ( isset($from) && isset($to) )
        <script type="text/javascript">

            $('input[name=from]').val('{{$from}}');
            $('input[name=to]').val('{{$to}}');

        </script>
    @endif
@endsection